package com.xingxue.module.user.repository;

import com.xingxue.module.user.entity.QuestionDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface QuestionDetailRepository extends JpaRepository<QuestionDetail, Integer> {

    @Query("select q.questionId from QuestionDetail q where q.userId=?1 and q.correct=true")
    List<Integer> findCorrectQuestion(int userId);

    @Query("select q.questionId from QuestionDetail q where q.userId=?1 and q.correct=false")
    List<Integer> findWrongQuestion(int userId);

    QuestionDetail findByUserIdAndQuestionId(int userId, int questionId);
}
